
import * as icons from '@element-plus/icons-vue'
const importFn = require.context('./', true, /\.vue$/)
export default {
  install (app: any) {
    // 批量注册全局组件
    importFn.keys().forEach(key => {
      // 导入组件
      const component = importFn(key).default
      // 注册组件
      app.component(component.name, component)
    })

    addComponents(app)
  }
}
// element icon 组件注册
function addComponents (APP: any) {
  const EL_ICON_OBJ: any = {
    ...icons
  }
  for (const key in EL_ICON_OBJ) {
    const component = getValue(key)
    APP.component(key, component)
  }
  function getValue (arg: keyof typeof EL_ICON_OBJ) {
    return EL_ICON_OBJ[arg]
  }
}
